Ext.define('WT.view.desktop.usermanager.CreateUserView',{
	extend:'Ext.window.Window',
	id:'create-user-win',
	//显示此窗口时遮罩其他组件
	modal:true,
	autoShow:true,
	title:'创建用户',
	width:800,
	height:500,
	layout:'fit',
	items:[{
		layout : 'card',
		activeItem : 0,
		defaults: {border: false},
		
		//card bbar start
		bbar: ['->',{
			id: 'move-prev',
			text: '上一页',
			handler: function(btn) {
				WT.view.desktop.usermanager.CreateUserView.navigate(btn.up("panel"), "prev");
			},
			disabled: true,
			iconCls:'create-user-pre'
			},
			'-',
			{
			id: 'move-next',
			text: '下一页',
			iconCls:'create-user-next',
			handler: function(btn) {
				WT.view.desktop.usermanager.CreateUserView.navigate(btn.up("panel"), "next");
			}},'-',
			{
				text:'完成',
				iconCls:'create-user-finsh',
				disabled: true,
				id:'create-user-finsh'
			
			},'-',{
				text:'取消',
				iconCls:'remove',
				id:'cancel'
			    
			}],
	    //card bbar end
			
	    //card items start
		items:[
		    
		    //第一个面板开始
		    {
		    xtype:'form',
		    id:'myform',
			defaults: {
        	labelSeparator :'：',
        	labelWidth : 60,
        	width:230
        	},
   			defaultType: 'textfield',
   			bodyStyle: {  
                padding: '15px'  //内间距 
            },
           
            // form start
            items: [
                    {
                    	 fieldLabel: '用户名',
                         name: 'userName',
                         style:'font-size:15px',
                         allowBlank:false,
                         id:'userName'
                         
                    },
                    {
                    	   fieldLabel: '密码',
                           name: 'password',
                           style: 'font-size: 15px',
                           inputType: 'password',
                           allowBlank:false,
                           id:'password'
                    },
                    {
                    	  fieldLabel: '确认密码',
                          name: 'password',
                          style: 'font-size: 15px',
                          inputType: 'password',
                          allowBlank:false,
                          id:'confirmPassword'
                    },
                    {
                    	xtype : 'radiogroup',
                        fieldLabel:'使用状态',
                        columns:2,
                        id:'status',
                        items:[{
                        	name:'status',
                        	inputValue:'1',
                        	boxLabel:'启用',
                        	checked:true
                        },{
                        	name:'status',
                        	inputValue:'2',
                        	boxLabel:'禁用'
                        }]
                    },
                    {
                    	xtype:'textarea',
                        name:'mark',
                        fieldLabel: '备注',
                        width:400  
                    }],
                
                buttons:[{
                	text: '提交',
                	formBind: true, 
                	handler: function() {
                	   var form = Ext.getCmp('myform').getForm(); 
                	   //alert(aaa);
                	   form.submit({ 
                		   url: '/wt/data/usermanager/userlist.json',
                		   mthod:'post',
                		   waitMsg: '正在提交表单请稍后......',
                		   success: function(form, action) {
                		      Ext.Msg.alert('Success', '保存成功!'); 
                	       },
                	       failure: function(form, action) {
                	    	   Ext.Msg.alert('Failed', '保存失败');
                	      } 
                	   });
                    }
                }]
                
                // form end
            
		},
		//第一个面板结束
		
		//第二个面板开始
		{
			border: false,
            xtype: 'grid',
            id:'createuser-role-grid',
          //dockedItems start
            dockedItems:[{    
                       	 dock:'bottom',    
                       	 xtype:'pagingtoolbar',    
                       	 displayInfo:true,    
                       	store:Ext.create('WT.store.usermanager.RoleListStore'),
                       	 displayMsg:'显示{0}-{1}条，共计{2}条',    
                       	 emptyMsg:'没有数据'    
                        }],
           //dockedItems end   
                        
           
            selModel: new Ext.selection.CheckboxModel,
           
            //columns start
            columns: [
                   
                {
                    text: "角色名",
                    flex:1,
                    sortable: true,
                    dataIndex: 'roleName',
                    id:'roleName'
                },
                {
                    text: "描述",
                    width: 150,
                    sortable: true,
                    dataIndex: 'description',
                    id:'description'
                }],
                store:Ext.create('WT.store.usermanager.RoleListStore')
          //columns end
		}
		//第二个面板结束
		]
		//card items end
	}],
	statics:{
		navigate:function(panel, direction){
        	var layout = panel.getLayout();
        	layout[direction]();
        	Ext.getCmp('move-prev').setDisabled(!layout.getPrev());
        	Ext.getCmp('move-next').setDisabled(!layout.getNext());
        	Ext.getCmp('create-user-finsh').setDisabled(!layout.getPrev());
        	}
	}
});